//
// Use MS-Word: [ Layout: PORTRAIT;  Margins: 0.5" all around;  Font: Consolas;  Font-size: 8 ]
//

// This program prints the study materials for a particular list or all the lists if not specified.
//
// For each list, its words are printed in two forms: "terse" and "full", and a list of just words.
// Then it prints two sets of tests, each with a multi-choice quiz and a cross-match quiz;
// each quiz covers all the words in the list.
// Finally, it prints the prefix counts for each list, to be used for fill-blank exercises.

function println(s) { java.lang.System.out.println(s); }

function genStudyMaterial(listShortName, pageWidth) {
    var outFileBase = "temp/" + listShortName + "/" + listShortName + "-";
    var s = "source=lists:" + listShortName + " out=" + outFileBase;
    wortubung.runCommand("/print   " + s + "words-terse.txt    pageWidth=" + pageWidth + " simple");
    wortubung.runCommand("/print   " + s + "words-full.txt     pageWidth=" + pageWidth + " complete");
    wortubung.runCommand("/print   " + s + "words-list.txt     pageWidth=" + pageWidth + " wordsOnly");
    wortubung.runCommand("/genquiz " + s + "test-mc1.txt pageWidth=" + pageWidth + " multichoice total=all");
    wortubung.runCommand("/genquiz " + s + "test-xm1.txt pageWidth=" + pageWidth + " crossmatch  total=all");
    wortubung.runCommand("/genquiz " + s + "test-mc2.txt pageWidth=" + pageWidth + " multichoice total=all");
    wortubung.runCommand("/genquiz " + s + "test-xm2.txt pageWidth=" + pageWidth + " crossmatch  total=all");

    wortubung.runCommand("/pw " + pageWidth);
    wortubung.runCommand("/verbose off");
    wortubung.runCommand("/pipe " + outFileBase + "prefix-counts.txt");
    wortubung.runCommand("/pipe clear");
    wortubung.runCommand("/prefixcount " + listShortName);
    wortubung.runCommand("/pipe off");
}


var listNames;
var pageWidth = 122;

if (typeof args != 'undefined')
    listNames = args;
else
    listNames = wortubung.getListShortNames();

println("The page width for the output is " + pageWidth + ".");
println("");

for (var i=0; i<listNames.length; ++i)
    genStudyMaterial(listNames[i], pageWidth);


println("");
println("Note: You can change the values in the script.");
println("Here are some suggested values if you plan to print from Microsoft Word:");
println('  1. (Layout: PORTRAIT;   Margins: 0.5" all around;  Font: Consolas;  Font-size: 9):  pageWidth = 109.');
println('  2. (Layout: PORTRAIT;   Margins: 0.5" all around;  Font: Consolas;  Font-size: 8):  pageWidth = 122.');
println('  3. (Layout: LANDSCAPE;  Margins: 0.5" all around;  Font: Consolas;  Font-size: 9):  pageWidth = 145.');
println('  4. (Layout: LANDSCAPE;  Margins: 0.5" all around;  Font: Consolas;  Font-size: 8):  pageWidth = 163.');
